<%@ page language="java" contentType="text/html; charset=windows-1255"
    pageEncoding="windows-1255"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="public/style.css" rel="stylesheet" type="text/css"/>
<%@page import="java.io.File"%>
<%@page import="BusinessLogic.Result.ResultType"%>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.LinkedList" %>
<%@ page import="BusinessLogic.Result" %>
<%@ page import="BusinessLogic.Session" %>
<%@ page import="BusinessLogic.CoursesContainer" %>
<%@ page import="BusinessLogic.Course" %>
<%@page import="BusinessLogic.User"%>
<title>Easy Schedule</title>
<script type="text/javascript" src="public/jquery.js"></script>
<script type="text/javascript">
	$(document).ready(function(){
		$('#searchForm').submit(function() {
			var name = $('#NAME').val();
			var desc = $('#DESCRIPTION').val();
			var points = $('#POINTS').val();
			var group = $('#GROUP_NUM').val();
			var Sunday = $('#Sunday').is(':checked');
			var Monday = $('#Monday').is(':checked');
			var Tuesday = $('#Tuesday').is(':checked');
			var Wednesday = $('#Wednesday').is(':checked');
			var Thursday = $('#Thursday').is(':checked');
			var Friday = $('#Friday').is(':checked');
			var Saturday = $('#Saturday').is(':checked');
			$.get(
				    "./searchExecute.jsp",
				    {DESCRIPTION:desc,POINTS:points,GROUP_NUM:group,Sunday:Sunday,Monday:Monday,Tuesday:Tuesday
				    	,Wednesday:Wednesday,Thursday:Thursday,
				    	Friday:Friday,Saturday:Saturday},
				    function(data) { $('#courses').html(data); },
				    "html"
				);

			  return false;
			});
	});
	function replaceSpaces(name){
		var s = name.replace(/\s/g,"1");
		return s;
	}
	function showCourseDetails(cName){
		$('#'+replaceSpaces(cName)).toggleClass('adminkey');
	}
	function registerCourse(me,name)
	{
		$.get(
			    "/tamirandevyatar/requestHandler",
			    { action: "register", USER_NAME: me ,COURSE : name},
			    function(data) { data=data+''; if (data.indexOf("success",0)<0) alert(data); 
			    location.reload(true);},
			    "html"
			);
	}
	function unregisterCourse(me,name)
	{
		$.get(
			    "/tamirandevyatar/requestHandler",
			    { action: "unregister", USER_NAME: me ,COURSE : name},
			    function(data) { data=data+''; if (data.indexOf("success",0)<0) alert(data); 
			    location.reload(true);},
			    "html"
			);
	}
	function onlyAvailable()
	{
		$("div.av").toggle();
	}
</script>
</head>
<body>
<div id="page">
	        <div id="header">
	            <h1><a href="./">Easy<span class="logo">Schedule</span></a></h1>
	            <p id="subtitle">Nice and easy registration system</p>
	        </div>
	        <div id="menu">
	            <ul>
	                <li class="left_menu"><a href="./">Home</a></li>
	                <li class="left_menu"><a href="./about.html">About</a></li>
	                <li class="left_menu"><a href="/tamirandevyatar/logout">Logout</a></li>
	            </ul>
	        </div>
	        <div id="main">	
	            <div id="sidebar">
	                <div class="box" id="sidebar_head">
	                      <h2><a id="loginAnchor">User</a></h2>
	                    <div class="box2">
                        <ul>
                            <li><a href="/tamirandevyatar/allCourses">Show courses</a></li>
                            <li><a href="/tamirandevyatar/search">Search courses</a></li>
                            <li><a href="/tamirandevyatar/timetable">My timetable</a></li>
                            <li><a href="/tamirandevyatar/update">Update my details</a></li>
                            <li><a href="/tamirandevyatar/users">View users</a></li>
	                        </ul>
	                    </div>
	                </div>		
	            </div><!-- sidebar -->    	              
	            <div id="content">
	                <div id="contheader">
	                    <h2>Enter some search parameters!</h2>
	                </div>		
	                <div id="content2" class="welcome">
	                <form id = "searchForm" action="" method="post">
					    	<table border="0">
					    	<tr>
					    	<td>
					    	<label for="DESCRIPTION">Keywords &nbsp;&nbsp;</label>
					    	</td>
					    	<td>
					    	<textarea cols="30" rows="3" name="DESCRIPTION" id="DESCRIPTION"></textarea>
							</td>
							</tr>
							<tr>
							<td>
							<label for="POINTS">Number of credit points&nbsp;&nbsp;</label>
					    	</td>
					    	<td>
					    	<input type="text" name="POINTS" id="POINTS"/>
	                        </td>
	                        </tr>
	                        <tr>
	                        <td>
							<label for="GROUP_NUM">Group number&nbsp;&nbsp;</label>
					    	</td>
					    	<td>
					    	<input type="text" name="GROUP_NUM" id="GROUP_NUM"/>
							</td>
							</tr>
							</table>
							<label for="DAY">Select preferred Days:&nbsp;&nbsp;</label>
							<div id="DAY">
							<table>
							<tr>
							<td>
							<input type="checkbox" name="Sunday" value="Sunday" id="Sunday"/>Sunday
							</td>
							<td>
							<input type="checkbox" name="Monday" value="Monday" id="Monday"/>Monday
							</td>
							<td>
							<input type="checkbox" name="Tuesday" value="Tuesday" id="Tuesday"/>Tuesday
							</td>
							<td>
							<input type="checkbox" name="Wednesday" value="Wednesday" id="Wednesday"/>Wednesday
							</td>
							</tr>
							<tr>
							<td>
							<input type="checkbox" name="Thursday" value="Thursday" id="Thursday"/>Thursday
							</td>
							<td>
							<input type="checkbox" name="Friday" value="Friday" id="Friday"/>Friday
							</td>
							<td>
							<input type="checkbox" name="Saturday" value="Saturday" id="Saturday"/>Saturday
							</td>
							</tr>
							</table>
							</div>
	                	<h2>
						    <input type="submit" value="Search" />
						    <input type="reset" value="Reset" />
						</h2>
	                </form>
	               <div id="courses" class="entry">
	               </div>
	                </div><!-- content2 -->								              
	            </div><!-- content -->                    
	            <div class="clearing">&nbsp;</div> 
	            <div id="footer">
	                <p><a href="http://www.cs.technion.ac.il/~cs236369/">Managing Data on the World-Wide Web</a></p>
	            </div>
	        </div><!-- main -->
	    </div><!-- page -->
</body>
</html>